home *** CD-ROM | disk | FTP | other *** search
- ---------------------------------------------------------------------------
- Welcome to the Chessboard component for Borland C++ Builder !
-
- version 2.0 - September 7th 1997
- ---------------------------------------------------------------------------
- What's New:
-
- Now drop a ChessComponent on a form and you have a complete
- multithreaded Chess application.
-
- The Chessboard Comonent has been linked to the engine of
- Tom's Simple Chess Program, a complete chess program that is very
- interesting if you take in consideration that the source is very little.
-
- -New Properties:
-
- bool Thinking (read-only)
- Is set to TRUE if the computer is thinking about a move.
-
- TThreadPriority ThinkingPriority
- Sets the priority of the thinking thread. Cannot be higher than tpNormal.
-
- int SearchDepth
- Sets the searchdepth of the chess engine. With each value the searchdepth
- is increased, the time it takes to calculate a move grows exponentially.
-
- bool ComputerPlaysBlack
- Lets the computer think and move automatically when it's black's turn.
-
- bool ComputerPlaysWhite
- Lets the computer think and move automatically when it's white's turn.
-
- -New Methods:
-
- void __fastcall CancelThinking(void)
- Stops calculating if the computer was thinking about a move.
-
- void __fastcall MoveNow (void)
- Starts calculating. The thinkingthread is being set to a state in which
- it produces moves. Function returns before calculation has completed.
-
- -New Events:
-
- OnThreefoldPosition
- Occurs when the board enters into a position for the third time in
- a game.
-
- ---------------------------------------------------------------------------
-
- Description:
-
- The Chessboard component provides a component for a complete
- multithreaded chess application. The chess engine comes from
- Tom's Simple Chess Program. It features a customizable 2D
- Chessboard that can keep track of a game and verify the legality
- of moves.
-
- It allows the programmer to trap the following events:
-
- LegalMove, Illegal Move, Capture, En Passant, Castling, Promotion,
- Check, Mate, Stale Mate, Threefold position and Only Two Kings Left.
-
- The colors, size, Pieces and Squares can be customized. The component
- can be resized at runtime.
-
- The Chessboard component for Borland C++ Builder
- comes with the following files:
-
- ChessBrd.cpp (source file), ChessBrd.h (header file),
- ChessBrd.dcr (resource file),ChessBrd.txt (current file),
- ChThread.Cpp (second source file) and ChThread.h (second header file).
- ---------------------------------------------------------------------------
- Installation of the component:
-
- Start Borland C++ Builder.
- Select "Component", "Install" ,"Add" and
- "Browse" and then browse to the file CHESSBRD.CPP. The component will
- appear on a tab called Chess.
- ---------------------------------------------------------------------------
- Product History:
-
- version 2.0 - September 1997
- * Linked the CPP version of the component to Tom's Simple Chess Program.
- * Added properties Thinking, ThinkingPriority, SearchDepth,
- ComputerPlaysBlack, ComputerPlaysWhite
- * Added methods MoveNow, CancelThinking
- * Added event OnThreefoldPosition
- * Got rid of the warning 'Duplicate Resources' for the
- PAS resource has now been separated from the CPP resource.
- version 1.11 - July 25th 1997
- * Small bug in PAS file did not allow compiling of the component.
- version 1.1 - July 23th 1997
- * Fixed bug: Pieces were not displayed properly when being dragged
- if the Chessboard were not the child of the form.
- * Fixed bug: The letters A-H were not displayed in the right position
- if WhiteOnTop were TRUE.
- * Removed property Align because it was put there without the
- intention.
- * Added property Enabled, which allows to lock the Chessboard
- * Added member function DrawChessPiece which allows displaying
- of a chess piece outside of the component.
- * Datatype Square is now being used consequently
-
- version 1.0 - June 20th 1997
- * Added PAS file for Delphi2 and Delphi3
- version 1.0 - June 11th 1997
- * initial version (C++ Builder only)
- ----------------------------------------------------------------------------
- Property Descriptions:
-
- bool BoardLines
- Determines whether lines will be drawn
- around the board and between the squares
-
- TBitmap BorderBitmap
- If assigned a value, this bitmap will be used to draw the border around
- the board. BorderColor will then be ignored.
-
- TColor BorderColor
- Sets the color of the border. Will be visible only if no value has
- been assigned to BorderBitmap.
-
- CastleSet CastlingAllowed
- This set stores whether castling is still allowed for each king in each
- for white while CastleSet>>BlackQueenSide will disable long castling
- for Black.
-
- bool ComputerPlaysBlack
- Lets the computer think and move automatically when it's black's turn.
-
- bool ComputerPlaysWhite
- Lets the computer think and move automatically when it's white's turn.
-
- TFont CoordFont
- Sets the font eventually used to display the coordinates around the board.
-
- int CurrentMove (read-only)
- Stores the current move of the game in the list. CurrentMove cannot be
- to change its value.
-
- TBitmap CustomPieceSet
- If assigned a legal value (that is a bitmap with a Width of
- 1.5 times its Height) this bitmap will be used as the new piece set
- instead of the default The bitmap should consist of 6 x 4 smaller square
- bitmaps of equal size. The order of the pieces should be: pawn, knight,
- bishop, rook, queen and king. The first row represents the white pieces,
- the third row represents the black pieces. The second and fourth row
- should be monochrome and will be used to determine the mask of the white
- and black pieces respectively. The pieces will not be shown in the place
- where the mask bitmap contains a non-zero value. This allows transparent
- drawing of the pieces on the board.
-
- CoordSet DisplayCoords
- Determines whether coordinates are being displayed around the screen.
- Examples: DisplayCoords<<West will display coordinates on the left of
- the board. DisplayCoords>>East will make disappear coordinates at the
- right of the board.
-
-
- Square EnPassant
- if EnPassant doesn't equal None, it contains the square on which
- an EnPassant capture can take place. If white moves for instance
- E2-E4, EnPassant will be set to the value E3 (on which the pawn
- can be taken). Legal values are: A3-H3, A6-H6
-
- TPen LineStyle
- Contains the linestyle eventually used to display lines between
- the squares and around the board.
-
- String Position
- The contents of the board are stored in this string which is
- always 64 characters long. The board is stored from square
- A8 through H8 to H1. Each character represents a piece on the
- board. The characters P, N, B, R, Q, K represent the pawn
- knight, bishop, rook, queen and king respectively.
- White pieces are uppercased, black pieces lowercased. Empty
- squares are represented by spaces.
- To quickly initialize a standard setup, fill the string
- with 'init'.
-
- bool Resizable
- Determines whether the ChessBoard can be resized. If TRUE,
- when the user moves the cursor over the right-down corner,
- the shape of the cursor will change and allow the ChessBoard
- to be resized. The resizing does not yet happen flicker-free.
-
- int ResizeMinSize
- The minimum allowed size of the ChessBoard (it's Width and Height)
- while it is in the resizing state.
-
- int ResizeMaxSize
- The maximum allowed size of the ChessBoard (it's Width and Height)
- while it is in the resizing state.
-
- int SearchDepth
- Sets the searchdepth of Tom's chess engine. With each point the
- searchdepth is increased, the time it takes to calculate a move grows
- exponentially.
-
- int SizeOfBorder
- Determines the width of the border around the board. Changing its
- value may change the size of the chessboard as well. (Width and Height)
-
- int SizeOfSquare
- Determines the squaresize. Changing its value may change the size of
- the chessboard as well. (Width and Height)
-
- TColor SquareColorDark
- The color of the dark squares. Will be visible only if no value has
- been assigned to SquareDark.
-
- TColor SquareColorLight
- The color of the light squares. Will be visible only if no value has
- been assigned to SquareLight.
-
- TBitmap SquareDark
- If assigned a value, this bitmap will be used to draw the border around
- the board to display the dark squares. SquareColorDark will then be
- ignored.
-
- TBitmap SquareLight
- If assigned a value, this bitmap will be used to display the light
- squares. SquareColorLight will then be ignored.
-
- StandardSet StandardSize
- Sets the size of the standard pieceset. The standard pieceset will
- only be used if no value has been assigned to CustomPieceSet.
- Legal values are: size32, size40, size64 and size80
-
- bool Thinking (read-only)
- Is set to TRUE if the computer is currently thinking about a move.
-
- TThreadPriority ThinkingPriority
- Sets the priority of the thinking thread. Cannot be higher than tpNormal so
- the stability does not get jeopardized.
-
- bool WhiteOnTop
- Controls whether the white pieces are being
- displayed on top of the board. Use: WhiteOnTop=!WhiteOnTop to flip the
- board.
-
- bool WhiteToMove
- Readonly. Sets the turn to white if TRUE and to black if FALSE;
- --------------------------------------------------------------------------
- Methods of the Public Interface:
-
- -Pieces can contain the following (char) values:
- p,b,n,r,q or k for a black pawn, knight bishop, rook queen or king
- P,B,N,R,Q or K for a white pawn, knight bishop, rook queen or king
-
- bool __fastcall BlackInCheckAfter(Square oldSq, Square newSq)
- returns TRUE if black is in check after the indicated move
-
- void __fastcall CancelThinking(void)
- Stops calculating if the computer was thinking about a move.
-
- bool __fastcall ClearSquare(int sqn)
- will empty the square with number sqn
-
- static int inline __fastcall ColorOfPiece (char piece)
- returns BLACK (0) or WHITE (1) if piece is a legal piece
- otherwise NOPIECE (-1)
-
- static int inline __fastcall ColorOfSquare (Square sqno)
- function ColorOfSquare (sq: Square): Integer
- returns BLACK or WHITE according to the color of square sqno.
-
- void __fastcall DrawChessPiece(TCanvas *canvas, int x, int y,char piece)
- procedure DrawChessPiece (canvas: TCanvas; x,y: Integer; piece: Char)
- Draws the Chess piece, indicated by 'piece' on the given canvas,
- at the given offset (x,y).
- This method uses some kind of MaskBlt, and draws only in the place
- where the mask has its bits set so drawing on a patterned surface
- is possible.
-
- MoveInfo& __fastcall GetMove (int moveno, bool WhiteMoves)
- Returns a MoveInfo structure filled with the information
- about the indicated move. Returns a structure with all
- zero values and an initial position in the case the
- move could not be found in the movelist.
-
- TStringList* __fastcall GetMoveList (void)
- Returns a TStringList with all the moves of the current game.
-
- bool __fastcall GotoMove (int moveno, bool WhiteMoves)
- Jump to the indicated move in the game and
- set the position accordingly. Returns FALSE if
- the move cannot be found in the movelist.
-
- bool __fastcall LegalMoveAvailable (void)
- Returns TRUE if a move can be made from the current position.
-
- static Square inline __fastcall MouseToSquare (int x, int y)
- converts coordinates to a square value.
- For instance CoordsToSquare (1,4) will return A4.
-
- bool __fastcall Move (Square oldSq, Square newSq)
- will make a move and return TRUE if the move is legal.
- The move will be both displayed on the board and registered in
- memory. For castling: pass the move of the king.
- Example: Move (E2,E4)
-
- bool __fastcall MoveBackward (void)
- Moves backward in the list of played moves and sets the position
- accordingly. Returns FALSE if there's no move available.
-
- void __fastcall MoveForward (void)
- Moves forward in the list of played moves and sets the position
- accordingly. Returns FALSE if there's no move available.
-
- void __fastcall MoveNow (void)
- Starts calculating. The thinkingthread is being set to a state
- in which it produces moves. Function returns before calculation
- has completed.
-
- void __fastcall NewGame(void)
- Resets the position to the initial state.
-
- bool __fastcall SetUpPosition (MoveInfo &pos, int moveno, bool whitemoves)
- Sets up the ChessBoard according to a given position. The first
- move in the game will be moveno.
-
- void __fastcall UpdateChessBoard (String oldpos)
- Ensures all pieces are displayed on the right position.
- Can be used if you change property Position manually.
-
- bool __fastcall WhiteInCheckAfter(Square oldsq, Square newsq)
- returns TRUE if white is in check after the indicated move
-
- Square __fastcall WindowToSquare (int x, int y)
- returns the square at the position of (x,y).
- x and y must be relative to the current window.
-
- static int inline __fastcall XPos (int sqno)
- returns the x-Coordinate (as an integer number in the range 1-8)
- of the square.
-
- static int inline __fastcall YPos (int sqno)
- returns the x-Coordinate (as an integer number in the range 1-8)
- of the square.
-
- ---------------------------------------------------------------------------
- Event Handlers:
-
- The following event handlers can be used.
-
- virtual void __fastcall Capture (System::TObject *Sender,
- int oldSq, int newSq, char CapturedPiece)
-
- virtual void __fastcall Castle (System::TObject *Sender, Square oldSq,
- Square newSq)
-
- virtual void __fastcall Check (System::TObject *Sender,
- Square oldSq, Square newSq)
-
- virtual void __fastcall Click(void)
-
- virtual void __fastcall DragCanceled(void)
-
- virtual void __fastcall DragDrop(System::TObject *Source,int X, int Y)
-
- virtual void __fastcall DragOver(System::TObject* Source, int X, int Y,
- TDragState State, bool &Accept )
-
- virtual void __fastcall EndDrag(bool drop)
-
- virtual void __fastcall IllegalMove (System::TObject *Sender, Square sq)
-
- virtual void __fastcall LegalMove (System::TObject *Sender,
- Square oldSq, Square newSq)
-
- virtual void __fastcall Mate (System::TObject *Sender,
- Square oldSq, Square newSq)
-
- virtual void __fastcall MouseDown(TMouseButton Button,
- Classes::TShiftState Shift, int X, int Y)
-
- virtual void __fastcall MouseMove(Classes::TShiftState Shift, int X, int Y)
-
- virtual void __fastcall MouseUp(TMouseButton Button,
- Classes::TShiftState Shift, int X, int Y)
-
- virtual void __fastcall OnlyTwoKingsLeft (System::TObject *Sender)
-
- virtual void __fastcall Paint(void)
-
- virtual void __fastcall Promotion
- (System::TObject *Sender, Square oldSq, Square newSq, char &NewPiece)
-
- virtual void __fastcall StaleMate (System::TObject *Sender,
- Square oldSq, Square newSq)
-
- virtual void __fastcall ThreefoldPosition (System::TObject *Sender)
-
- ------------------------------------------------------------------------------
-
- Copyright, Liability and Author:
-
- The Chessboard component may be freely used and distributed by anyone.
- The author does not accept liability for the software in any way.
-
- Note that the standard pieceset that's being used comes straight out of
- Fritz4 for I thought I would never be able to design such clear and charming
- pieces. So take care not to break any laws with copyrighted material.
- If you would like to receive some Chess pieces from some other popular
- Chess programs, just drop me a line, which you can do as well if you
- have any bug reports, comments, suggestions, or wanted features:
-
- Daniel Terhell
- Amsterdam
- Tel: +31 20 4866128
- kr8m8pr8@compuserve.com
- http://ourworld.compuserve.com/homepages/kr8m8pr8
- ------------------------------------------------------------------------------
-
-